<?

/* Dataxi installation and administration script
 *
 * This collection of functions (library) is licensed under GPL2.
 * See LICENSE or www.gnu.org for more details.
 */


include_once("sogeneric.php");
include_once("dzgeneric.php");

if (1 == 1) {
    dzadmin_collect();
} else {
    die("Access denied, thank you for trying.");
};

/* END OF MAIN */

function dzadmin_collect() {

    /* Site settings */
    $ini = dzGetSiteIni();
    $paths = array();
    $paths[] = array("Site includes", "site_inc", 
        $ini->getValue(DZIS_FOLDERS, DZID_SITE_INC_FOLDER, 0));
    $paths[] = array("Temporary files", "site_tmp", 
        $ini->getValue(DZIS_FOLDERS, DZID_SITE_TMP_FOLDER, 0));
    $paths[] = array("Cache files", "cache", 
        $ini->getValue(DZIS_FOLDERS, DZID_CACHE_FOLDER, 0));
    $paths[] = array("Form sources", "forms", 
        $ini->getValue(DZIS_FOLDERS, DZID_FORM_SOURCE_FOLDER, 0));
    $paths[] = array("Ini files", "ini", 
        $ini->getValue(DZIS_FOLDERS, DZID_INI_FOLDER, 0));
    $appname = array("Application name", "appname", 
        $ini->getValue(DZIS_GENERAL, DZID_APPNAME, 0));
    echo "<html><head><title>Dataxi administration</title></head>".
         "<body><h1>Dataxi administration</h1>\n".
         "<form name=admin method=post action=".$PHP_SELF.">\n".
         "<table>\n".
         "<tr><td colspan=2><h3>Site folders & settings</h3></td></tr>\n";
    foreach ($paths as $path) {
         if (!count($path)) {
            echo "<tr><td colspan=2><br></td></tr>\n";
        } else {
             echo "<tr><td>".$path[0].":</td>".
                  "<td><input name=".$path[1]." value=".
                  $path[2]."></td></tr>\n";
        };
    };

    /* Application settings */
    echo "<tr><td colspan=2><br><h3>Application settings</h3></td></tr>\n";
    $ini = dzGetIni("app");
    $paths = array($appname);
    $paths[] = array("Default language code", "lang", 
        $ini->getValue(DZIS_GENERAL, DZID_LANG, 0));
    $paths[] = array("Date format string", "data", 
        $ini->getValue(DZIS_GENERAL, DZID_DATE, 0));
    $paths[] = array("Time format string", "time", 
        $ini->getValue(DZIS_GENERAL, DZID_TIME, 0));
    $paths[] = array("Datetime format string", "datetime", 
        $ini->getValue(DZIS_GENERAL, DZID_DATETIME, 0));
    $paths[] = array("Database alias name", "dbalias", 
        $ini->getValue(DZIS_GENERAL, DZID_DBALIAS, 0));
    $paths[] = array("Database translations table", "dbtt", 
        $ini->getValue(DZIS_GENERAL, DZID_DBTT, 0));
    $paths[] = array("Allow suspend", "suspend", 
        soGetBoolValue($ini->getValue(DZIS_GENERAL, DZID_ALLOW_SUSPEND, 0)),
        "checkbox");
    $paths[] = array("Open new window on startup", "open_new", 
        soGetBoolValue($ini->getValue(DZIS_GENERAL, DZID_OPEN_WINDOW, 0)),
        "checkbox");
    $paths[] = array("Show browsers status bar", "status_bar", 
        soGetBoolValue($ini->getValue(DZIS_GENERAL, DZID_OPEN_WINDOW, 0)),
        "checkbox");

    $paths[] = array("Layout settings");
    $paths[] = array("Auto format layout", "format", 
        soGetBoolValue($ini->getValue(DZIS_LAYOUT, DZID_FORMAT, 0)),
        "checkbox");
    $paths[] = array("Border", "border", 
        soGetBoolValue($ini->getValue(DZIS_LAYOUT, DZID_BORDER, 0)),
        "checkbox");
    $paths[] = array("Spacing", "spacing", 
        intval($ini->getValue(DZIS_LAYOUT,  DZID_SPACING, 0)));
    $paths[] = array("Padding", "padding", 
        intval($ini->getValue(DZIS_LAYOUT, DZID_PADDING, 0)));
    $paths[] = array("Guru settings");
    $paths[] = array("Remote kone address", "kone", 
        $ini->getValue(DZIS_GENERAL, DZID_KONE, 0));
    $paths[] = array("Kone has struct cache access", "kone", 
        soGetBoolValue($ini->getValue(DZIS_GENERAL, DZID_KONE_ACCESS_CACHE, 0)),
        "checkbox");
    foreach ($paths as $path) {
         if (count($path) < 2) {
            echo "<tr><td colspan=2><br>".$path[0]."</td></tr>\n";
        } else {
            if (!$path[3]) $path[3] = "text";
            $checked = "";
            if (($path[3] == "checkbox") && ($path[2])) $checked = "checked";
            echo "<tr><td>".$path[0].":</td>".
                 "<td><input type=".$path[3]." $checked ".
                 "name=".$path[1]." value=".
                 $path[2]."></td></tr>\n";
        };
    };


    echo "</table></form></body></html>\n";

}; // dzadmin

?>
